package pack9999;

import java.util.Arrays;
import java.util.Scanner;

public class DemoC {
    public static void a() {
        int[] score = {60, 80, 90, 70, 85};
        double avg;
        avg = (score[0] + score[1] + score[2] + score[3] + score[4]) / 5;
        System.out.println(avg);

    }

    public static void b() {
        int[] num = {8, 4, 2, 1, 23, 344, 12};
        for (int i = 0; i < 7; i++) {
            System.out.println(num[i]);
        }
    }

    public static void c() {
        int len = (int) (Math.random() * 20 + 10);
        int[] array = new int[len];
        for (int i = 0; i < len; i++) {
            array[i] = (int) (Math.random() * 100 + 1);
        }
        System.out.println(Arrays.toString(array));
        Scanner scan = new Scanner(System.in);
        int number = scan.nextInt();
        boolean flag = false;
        for (int i = 0; i < array.length; i++) {
            if (number == array[i]) {
                flag = true;
                break;
            }
        }
        System.out.print(flag ? "存在" : "不存在");
    }

    public static void d() {
        int len = (int) (Math.random() * 20 + 10);
        int[] array = new int[len];
        for (int i = 0; i < len; i++) {
            array[i] = (int) (Math.random() * 100 + 1);
        }
        System.out.println(Arrays.toString(array));
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));
        int begin = 0;
        int end = len - 1;
        int millde = (begin + end) / 2;
        if (num == array[begin] || num == array[end]) {
            System.out.println("存在");
            return;
        }
        while (begin < end - 1) {
            if (num > millde) {
                begin = millde;
                millde = (begin + end) / 2;
            } else if (num < millde) {
                end = millde;
                millde = (begin + end) / 2;
            } else {
                System.out.println("存在");
                return;
            }
        }
        System.out.println("存在");
    }

    public static void e(){

    }
    public static void main(String[] args) {
        d();
    }
}
